import { h, render, Component,Fragment } from "../lib/preact.js";
import { useState, useEffect, useCallback, useContext, useRef  } from "../lib/hooks.js";
import ClockX from '../components/Test.js';
import Container from '../components/Container.js';

export default class App extends Component {
  state = { time: Date.now() };

  // Called whenever our component is created
  componentDidMount() {
    // update time every second
    this.timer = setInterval(() => {
      this.setState({ time: Date.now() });
    }, 1000);
  }

  // Called just before our component will be destroyed
  componentWillUnmount() {
    // stop when not renderable
    clearInterval(this.timer);
  }

  render() {
    let time = new Date(this.state.time).toLocaleTimeString();
    return <div><span>{time}</span><p><ClockX></ClockX><Container></Container></p></div>;
  }
}